<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="../js/tools/jquery-1.4.2.min.js"></script>
<style>
  body{background-color:#ffffff;}
  table{table-layout:fixed;font-size:12px;}
  tr{background-color:#F1F6F6;}
  td{border:1px solid #D9D9D9;color:black;padding:2px;}
  td a{text-decoration:none;}
  .acss{background-color:#982987;color:#FFFFFF; padding-right:3px; padding-left:3px;}
  #allTargs a{text-decoration:none;table-layout:fixed;font-size:14px;margin-right:8px;}
</style>
<script type="text/javascript">
$(document).ready(function(){
   
      var targs = new Array(${tags});
      
       var allTargs="";
     
     for(var i=0;i<targs.length;i++)
      {
         allTargs+="<a href='javascript:void(0);' onclick='delTags(this,\""+targs[i]+"\")'>"+targs[i]+"</a>";
      }
      $("#allTargs").html(allTargs);
     
});
function addTags()
{
  var tag=$("#tag").val();
 
  var tid=$("#tid").val();
 
  if(tag=="")
  {
      alert("关键词不能为空!");
     return false;
  }
  if($("#allTargs").text().indexOf(tag)!=-1)
  {
     alert("该关键词已经存在!");
     return false;
  }
  if(tag!="")
  {
  var date= new Date();
   $.getJSON("../groupbyajax/user!addTags.action?times="+date.getTime(),{tags:tag},function(data){
              
					      if(data.success)
					      {
					       $("#allTargs").append("<a href='javascript:void(0);' onclick='delTags(this,\""+tag+"\")'>"+tag+"</a>");
					      } 
	})
  }
}
function delTags(obj,tags)
{
$(obj).remove();
var date= new Date();
    $.getJSON("../groupbyajax/user!delTags.action?times="+date.getTime(),{tags:tags},function(data){
                  
	})
}
</script>
</head>

<body>
  <div>
  <input type="hidden" id="tid" name="tags" value='<s:property value="tags" escape="false"/>'>
  	<table align="center" width="68%">
		     <tr>  
		       <td width="20%">添加团购关键词</td> 
		       <td ><input type="text" id="tag"/><button onclick="addTags()">添加</button></td>
		     </tr> 
		     <tr>  
		       <td >已有添加关键词</td> 
		       <td ><div id="allTargs" style="float:left;height:400px;border:1px solid #D9D9D9;color:black;padding:2px;overflow: auto;"></td>
		     </tr>
      
  	</table>
  </div>
</body>
</html>